package cart.api.vo;

import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;
import java.util.List;

/**
 * 临时订单Vo
 * Created by Liang Wenxu on 2017/1/19.
 */
public class TempOrderVo implements Serializable {
    /**
     * 临时订单号
     */
    private String tmpOrderNo;

    /**
     * 创建时间
     */
    private Date createTime;

    /**
     * 订单总价
     */
    private BigDecimal sumPrice;

    /**
     * 订单总运费
     */
    private BigDecimal sumShippingFee;

    /**
     * 临时订单店铺列表
     */
    private List<TempOrderStoreVo> storeList;

    /**
     * 订单礼品
     */
    private List<TmpOrderGiftVo> tmpOrderGifts;

    /**
     * 订单扩展属性
     */
    private List<OrderAttrVo> orderAttrs;

    /**
     * 判断是否使用积分兑换 1是  0否
     */
    private String useScore;

    /**
     * 订单用途代码
     */
    private String usageCode;

    /**
     * 返回总商品数量(一个商品购买多件仍视为一个商品)
     * @return int 商品数量合计
     */
    public int getSumGoodsCount() {
        int sumGoodsCount = 0;
        for(TempOrderStoreVo storeVo : storeList) {
            for(TempOrderItemVo itemVo : storeVo.getOrderItems()) {
                sumGoodsCount += 1;
            }
        }

        return sumGoodsCount;
    }

    /**
     * 返回购买商品件数合计（计算各商品的购买件数）
     * @return int 商品数量合计
     */
    public int getSumGoodsBuyCount() {
        int sumGoodsCount = 0;
        for(TempOrderStoreVo storeVo : storeList) {
            for(TempOrderItemVo itemVo : storeVo.getOrderItems()) {
                sumGoodsCount += itemVo.getCount();
            }
        }

        return sumGoodsCount;
    }

    public String getTmpOrderNo() {
        return tmpOrderNo;
    }

    public void setTmpOrderNo(String tmpOrderNo) {
        this.tmpOrderNo = tmpOrderNo;
    }

    public Date getCreateTime() {
        return createTime;
    }

    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }

    public List<TempOrderStoreVo> getStoreList() {
        return storeList;
    }

    public void setStoreList(List<TempOrderStoreVo> storeList) {
        this.storeList = storeList;
    }

    public List<TmpOrderGiftVo> getTmpOrderGifts() {
        return tmpOrderGifts;
    }

    public void setTmpOrderGifts(List<TmpOrderGiftVo> tmpOrderGifts) {
        this.tmpOrderGifts = tmpOrderGifts;
    }

    public BigDecimal getSumPrice() {
        return sumPrice;
    }

    public void setSumPrice(BigDecimal sumPrice) {
        this.sumPrice = sumPrice;
    }

    public BigDecimal getSumShippingFee() {
        return sumShippingFee;
    }

    public void setSumShippingFee(BigDecimal sumShippingFee) {
        this.sumShippingFee = sumShippingFee;
    }

    public String getUseScore() {
        return useScore;
    }

    public void setUseScore(String useScore) {
        this.useScore = useScore;
    }

    public String getUsageCode() {
        return usageCode;
    }

    public void setUsageCode(String usageCode) {
        this.usageCode = usageCode;
    }

    public List<OrderAttrVo> getOrderAttrs() {
        return orderAttrs;
    }

    public void setOrderAttrs(List<OrderAttrVo> orderAttrs) {
        this.orderAttrs = orderAttrs;
    }
}
